<?php
namespace Custom\WebBundle\Controller;

use Topxia\WebBundle\Controller\BaseController;
use Topxia\WebBundle\Handler;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;


class DefaultController extends BaseController
{
	public function indexAction()
	{
        return $this->render('TopxiaWebBundle:Default:test.html.twig');
	}
	
	public function statisticsaAction(){
		$res = $this->getZhishidianService()->getkeshi();
		$res *= 60*60;		//把小时转换成秒
		$keshi = array();
		$keshi['hour'] = floor($res / 3600);
		
		$res -= $keshi['hour'] * 3600;
		
		$keshi['minu'] = floor($res / 60);
		
		$res -= $keshi['minu'] * 60;
		
		$keshi['sec'] = $res;
		
		return $this->render('CustomWebBundle:Default:statisticsa.html.twig',array(
		'keshi'=>$keshi
		));
	}
	
	public function statisticsbAction(){
	
		$res = $this->getuserService()->getnum();
		$res['keshinum'] = $this->getZhishidianService()->getkeshinum();
		$res['questionnum'] = $this->getQuestionService()->getquestionnum();
		$res['now'] = date('Y-m-d',time());
		return $this->render('CustomWebBundle:Default:statisticsb.html.twig',array(
		'res'=>$res
		));
	}
	
	public function MemberRankByUserCoursesAction(){
		
		$res = $this->getlessonlearnService()->getxueba(18);
		foreach ($res as $k=>$v){
			$res[$k]['mediumAvatar'] = str_replace('public:/','files',$v['mediumAvatar']);
		}
		return $this->render('CustomWebBundle:Default:xuebapaihang.html.twig',array(
			'xueba'=>$res
		));
	}
	
	protected function getQuestionService(){
		return $this->getServiceKernel()->createService('Kuke.QuestionService');
	}
	
	protected function getZhishidianService(){
		return $this->getServiceKernel()->createService('Kuke.ZhishidianService');
	}
	
	protected function getuserService(){
		return $this->getServiceKernel()->createService('Kuke.UserService');
	}
	
	protected function getlessonlearnService(){
		return $this->getServiceKernel()->createService('Kuke.LessonLearnService');
	}
}